<%@ include file="/WEB-INF/jspf/directive/taglib.jspf"%>

<html>

<c:set var="title">
	<fmt:message key="accounts.title.text" />
</c:set>
<%@ include file="/WEB-INF/jspf/head.jspf"%>

<body>

	<div class="container">
		<c:choose>
			<c:when test="${fn:length(accounts) == 0}">
				<h3><fmt:message key="accounts.label.noaccounts" /></h3>
			</c:when>

			<c:otherwise>
				<h3><fmt:message key="accounts.label.youraccounts" />:</h3>
				<table class="table table-bordered">
					<thead>
						<tr>
							<td><fmt:message key="accounts.label.accountuid" /></td>
							<td><fmt:message key="accounts.label.currentbalance" /></td>
							<td><fmt:message key="accounts.label.valutatype" /></td>
							<td><fmt:message key="accounts.label.state" /></td>
							<td><fmt:message key="accounts.label.actions" /></td>
						</tr>
					</thead>
					<c:forEach var="account" items="${sessionScope['accounts']}">
						<tr>
							<td><c:out value="${account.id}"></c:out></td>
							<td><c:out value="${account.balance}"></c:out></td>
							<td><c:out value="${account.valuta.shortName}"></c:out></td>
							<td><c:out value="${account.accountState}"></c:out></td>
							<td>
								<form action="controller" name="formView${account.id}">
									<input type="hidden" name="command" value="viewAccount">
									<input type="hidden" name="id"
										value=<c:out value="${account.id}"></c:out>> <a
										href=""
										onclick="document.forms['formView${account.id}'].submit(); return false;">
										<fmt:message key="accounts.button.view" /> </a>
								</form>
							</td>
						</tr>
					</c:forEach>

				</table>

			</c:otherwise>
		</c:choose>

		<a href="controller?command=browseAccountCreation"
			class="btn btn-large btn-block"><fmt:message key="accounts.button.createnew" /></a> <br> <a
			href="controller?command=browseUserPage"
			class="btn btn-large btn-block"><fmt:message key="accounts.button.back" /></a>

	</div>

</body>
</html>